<script setup lang="ts">
// 调用接口
const uoload = async () =>{
  //调用接口，并或返回值
  var result = await window.electron.ipcRenderer.sendSync('uoload', "D:/test/test.txt")
  console.log(result)
}

//订阅后台信息,后台消息推送
var listenered = false;
const message = () => {
  if (!listenered) { //防止重复订阅
    //监听(订阅主题receive-message)来自主进程的消息
    window.electron.ipcRenderer.on('receive-message', (_event, message) => {
      console.log(message);
    });
    //向主进程发送推送消息
    window.electron.ipcRenderer.send('push-message', '000000000');
    listenered = true;
  }else{
    console.log("已经订阅过")
  }
  
}

</script>

<template>
  <div>
    <!-- 按钮 -->
    <div style="height: 40px;width: 100%;text-align: left;margin-top: 10px;">
      <el-button type="primary" @click="uoload">上传文件</el-button>
      <el-button type="primary" @click="message">订阅信息</el-button>
    </div>
  </div>
</template>
